home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 292_02 / ast09.asm < prev    next >
Assembly Source File  |  1990-07-16  |  51KB  |  1,724 lines

  1.     .title    assist09 - mc6809 monitor
  2.  
  3.     .module    assist09
  4.  
  5.     .radix    d
  6.  
  7.     ;*  Modification date:  November 23, 1988
  8.  
  9.     ;********************************************************
  10.     ;*  miscelaneous    equates
  11.     ;********************************************************
  12.  
  13. dftchp    =    0        ; default character pad count
  14. dftnlp    =    0        ; default new line pad count
  15. prompt    =    '>        ; prompt character
  16. numbkp    =    8        ; number of breakpoints
  17.  
  18. eot    =    0x04        ; end of transmission
  19. bell    =    0x07        ; bell character
  20. lf    =    0x0a        ; line feed
  21. cr    =    0x0d        ; carriage return
  22. can    =    0x18        ; cancel (ctl-x)
  23.  
  24.     .page
  25.     .sbttl    SWI Functions
  26.  
  27.     ;********************************************************
  28.     ;* assist09 monitor swi functions
  29.     ;*
  30.     ;*  the following equates define functions provided
  31.     ;*  by the assist09 monitor via the swi instruction.
  32.     ;********************************************************
  33.  
  34. inchnp    =    0        ; input char in a reg - no parity
  35. outch    =    1        ; output char from a reg
  36. pdata1    =    2        ; output string
  37. pdata    =    3        ; output cr/lf then string
  38. out2hs    =    4        ; output two hex and space
  39. out4hs    =    5        ; output four hex and space
  40. pcrlf    =    6        ; output cr/lf
  41. space    =    7        ; output a space
  42. monitr    =    8        ; enter assist09 monitor
  43. vctrsw    =    9        ; vector examine/switch
  44. brkpt    =    10        ; user program breakpoint
  45. pause    =    11        ; task pause function
  46. numfun    =    11        ; number of available functions
  47.  
  48.     ;* sub-codes for accessing the vector table.
  49.     ;* they are equivalent to offsets in the table.
  50.     ;* relative positioning must be maintained.
  51.  
  52. .avtbl    =    0        ; address of vector table
  53. .cmdl1    =    2        ; first command list
  54. .rsvd    =    4        ; reserved hardware vector
  55. .swi3    =    6        ; swi3 routine
  56. .swi2    =    8        ; swi2 routine
  57. .firq    =    10        ; firq routine
  58. .irq    =    12        ; irq routine
  59. .swi    =    14        ; swi routine
  60. .nmi    =    16        ; nmi routine
  61. .reset    =    18        ; reset routine
  62. .cion    =    20        ; console on
  63. .cidta    =    22        ; console input data
  64. .cioff    =    24        ; console input off
  65. .coon    =    26        ; console output on
  66. .codta    =    28        ; console output data
  67. .cooff    =    30        ; console output off
  68. .hsdta    =    32        ; high speed printdata
  69. .bson    =    34        ; punch/load on
  70. .bsdta    =    36        ; punch/load data
  71. .bsoff    =    38        ; punch/load off
  72. .pause    =    40        ; task pause routine
  73. .expan    =    42        ; expression analyzer
  74. .cmdl2    =    44        ; second command list
  75. .pad    =    46        ; character pad and new line pad
  76. .echo    =    48        ; echo/load and null bkpt flag
  77.  
  78. numvtr    =    48/2+1        ; number of vectors
  79. hivtr    =    48        ; highest vector offset
  80.  
  81.     .page
  82.     .sbttl    Work Area
  83.  
  84.     ;********************************************************
  85.     ;* work area
  86.     ;*
  87.     ;*  The direct page register during most routine
  88.     ;*  operations will point to this work area.  the Stack
  89.     ;*  initially starts under the reserved work areas as
  90.     ;*  defined herein.
  91.     ;********************************************************
  92.  
  93.     .area    WORKPG    (ABS,OVR)
  94.     .setdp    0
  95.  
  96. workpg:                ; beginning of work aera
  97.  
  98. .blkb    0d256-(endpg-astack)    ; stack space
  99.  
  100. astack:                ; top of assist09 stack
  101. tstack:    .blkb    0d21        ; temporary stack hold
  102. delim:    .blkb    1        ; expression delimiter/work byte
  103. misflg:    .blkb    1        ; load cmd/thru breakpoint flag
  104. swicnt:    .blkb    1        ; trace "swi" nest level count
  105. pcnter:    .blkb    2        ; last program counter
  106. pstack:    .blkb    2        ; command recovery stack
  107. rstack:    .blkb    2        ; reset stack pointer
  108. anumber:.blkb    2        ; binary build area
  109. basepg:    .blkb    1        ; base page value
  110. addr:    .blkb    2        ; address pointer value
  111. window:    .blkb    2        ; window
  112. bkptop:    .blkb    0x10        ; breakpoint opcode table
  113. bkptbl:    .blkb    0x10        ; breakpoint table
  114. vectab:    .blkb    0x32        ; vector table
  115. bkptct:    .blkb    1        ; breakpoint count
  116. swibfl:    .blkb    1        ; bypass swi as breakpoint flag
  117. pauser:    .blkb    4        ; pause routine
  118. endpg:
  119.  
  120.     .page
  121.     .sbttl    Assist09 Code
  122.  
  123.     .area    ASSIST09 (ABS,OVR)
  124.  
  125.     ;********************************************************
  126.     ;* bldvtr - build assist09 vector table
  127.     ;*
  128.     ;*  hardware reset calls this subroutine to build the
  129.     ;*  assist09 vector table.
  130.     ;*
  131.     ;*  input: s->valid stack ram
  132.     ;*  output: u->vector table address
  133.     ;*         dpr->assist09 work area page
  134.     ;*         the vector table and defaults are initialized
  135.     ;*
  136.     ;*  all registers volatile
  137.     ;********************************************************
  138.  
  139. bldvtr:    leax    vectab,pcr    ; address vector table
  140.     tfr    x,d        ; obtain base page address
  141.     tfr    a,dp        ; setup dpr
  142.     sta    *basepg        ; store for quick reference
  143.     leau    ,x        ; return table to caller
  144.     stu    ,x++        ; and init vector table address
  145.     ldb    #numvtr-3    ; number relocatable vectors
  146.     pshs    b        ; store index on stack
  147.     leay    initvt,pcr    ; load from addr
  148. 1$:    tfr    y,d        ; prepare address resolve
  149.     addd    ,y++        ; to absolute address
  150.     std    ,x++        ; into vector table
  151.     dec    ,s        ; count down
  152.     bne    1$        ; branch if more to insert
  153.     ldb    #intve-intvs    ; static value init length
  154. 2$:    lda    ,y+        ; load next byte
  155.     sta    ,x+        ; store into position
  156.     decb            ; count down
  157.     bne    2$        ; loop until done
  158.     puls    pc,b        ; return to initializer
  159.  
  160.     ;********************************************************
  161.     ;* reset entry point
  162.     ;*
  163.     ;*  hardware reset enters here if assist09 is enabled
  164.     ;*  to receive the mc6809 hardware vectors.  we call
  165.     ;*  the bldvtr subroutine to initialize the vector
  166.     ;*  table, stack, and then fireup the monitor via swi
  167.     ;*  call.
  168.     ;********************************************************
  169.  
  170. reset:    leas    astack,pcr    ; setup initial stack
  171.     bsr    bldvtr        ; build vector table
  172. 1$:    clra            ; issue startup message
  173.     tfr    a,dp        ; default to page zero
  174.     swi            ; perform monitor fireup
  175.     .byte    monitr        ; to enter command processing
  176.     bra    1$        ; reenter monitor if 'continue'
  177.  
  178.     .page
  179.     .sbttl    Vector Table
  180.  
  181.     ;********************************************************
  182.     ;* initvt - initialize vector table
  183.     ;*
  184.     ;*  this table is relocated to ram and represents the
  185.     ;*  initial state of the vector table. all addresses
  186.     ;*  are converted to absolute form.  this table starts
  187.     ;*  with the second entry, ends with static constant
  188.     ;*  initialization data which carries beyond the table.
  189.     ;********************************************************
  190.  
  191. initvt:    .word    cmdtb1-.    ; default first command table
  192.     .word    rsrvdr-.    ; default undefined hardware vector
  193.     .word    swi3r-.        ; default swi3
  194.     .word    swi2r-.        ; default swi2
  195.     .word    firqr-.        ; default firq
  196.     .word    irqr-.        ; default irq routine
  197.     .word    swir-.        ; default swi routine
  198.     .word    nmir-.        ; default nmi routine
  199.     .word    reset-.        ; restart vector
  200.     .word    cion-.        ; default cion
  201.     .word    cidta-.        ; default cidta
  202.     .word    cioff-.        ; default cioff
  203.     .word    coon-.        ; default coon
  204.     .word    codta-.        ; default codta
  205.     .word    cooff-.        ; default cooff
  206.     .word    hsdta-.        ; default hsdta
  207.     .word    bson-.        ; default bson
  208.     .word    bsdta-.        ; default bsdta
  209.     .word    bsoff-.        ; default bsoff
  210.     .word    cpause-.    ; default pause routine
  211.     .word    exp1-.        ; default expression analyzer
  212.     .word    cmdtb2-.    ; default second command table
  213.  
  214.     ;* constants
  215.     ;*
  216. intvs:    .byte    dftchp,dftnlp    ; default null padds
  217.     .word    0        ; default echo
  218.     .byte    0        ; initial breakpoint count
  219.     .byte    0        ; swi breakpoint level
  220.     rts            ; default pause routine
  221. intve    =    .
  222.  
  223.     .page
  224.     .sbttl    SWI Handler
  225.  
  226.     ;********************************************************
  227.     ;* assist09 swi handler
  228.     ;*
  229.     ;*  the swi handler provides all interfacing necessary
  230.     ;*  for a user program.  a function byte is assumed to
  231.     ;*  follow the swi instruction.  it is bound checked
  232.     ;*  and the proper routine is given control.  this
  233.     ;*  invocation may also be a breakpoint interrupt.
  234.     ;*  if so, the breakpoint handler is entered.
  235.     ;*
  236.     ;* input: machine state defined for swi
  237.     ;* output: varies according to function called. pc on
  238.     ;*
  239.     ;*     callers stack incremented by one if valid call.
  240.     ;* volatile registers: see functions called
  241.     ;*
  242.     ;* state: runs disabled unless function clears i flag.
  243.     ;********************************************************
  244.  
  245.     ;* swi function vector table
  246.  
  247. swivtb:    .word     zinch-swivtb    ; inchnp
  248.     .word    zotch1-swivtb    ; outch
  249.     .word    zpdta1-swivtb    ; pdata1
  250.     .word    zpdata-swivtb    ; pdata
  251.     .word    zot2hs-swivtb    ; out2hs
  252.     .word    zot4hs-swivtb    ; out4hs
  253.     .word    zpcrlf-swivtb    ; pcrlf
  254.     .word    zspace-swivtb    ; space
  255.     .word    zmontr-swivtb    ; monitr
  256.     .word    zvswth-swivtb    ; vctrsw
  257.     .word    zbkpnt-swivtb    ; bre